﻿@model DroidClaim.Web.Models.SurveyorModel

@{
    Layout = null;
}
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />    
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.20.min.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () { 

            $('.grid th').each(function () {
                if (this.innerHTML == "") {
                    this.innerHTML = "<input type='checkbox' id='chkHeader'  />";
                }
            });

            $('.grid th input:checkbox').click(function (e) {
                var table = $(e.target).closest('table');
                $('td input:checkbox', table).attr('checked', e.target.checked);
            });
        });

        function SetOpener(Id, Code, Name)
        {
            //alert(Id);
								window.opener.document.getElementById("ClaimInfo_Surveyor").value = Id;
					window.opener.document.getElementById("ClaimInfo_SurveyorCode").value = Code;
					window.opener.document.getElementById("ClaimInfo_SurveyorName").value = Name;
				            window.close();
        }
    </script>  

<h2>Surveyor</h2>
<body style="padding:10px 10px 10px 10px">
@{  
    if (Model.ListOfSurveyor != null && Model.ListOfSurveyor.Count > 0)
    {
        var grid = new WebGrid(
            source: Model.ListOfSurveyor, canPage: false);
        @grid.GetHtml(
        tableStyle: "tableMain grid",
        rowStyle: "row-a",
        alternatingRowStyle: "row-b",
        columns: grid.Columns(          
          grid.Column(header: "Code", columnName: "Code", style: "width_10per"),
          grid.Column(header: "Name", style: "width_15per", columnName: "Name",
            format: item =>
            {
                string link = "<a href=\"#\" class=\"word_wrap\" onclick=\"SetOpener('{0}','{1}','{2}');\">{2}</a>";
                return Html.Raw(string.Format(link, item.Id, item.Code, item.Name));
            })

			                   , grid.Column(header: "SurveyerId", style: "width_100per", columnName: "SurveyerId",
						format: item =>
						{
							string SurveyerId = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(SurveyerId, String.IsNullOrWhiteSpace(item.SurveyerId+"") ? "" : item.SurveyerId));
						 })
                   , grid.Column(header: "Username", style: "width_100per", columnName: "Username",
						format: item =>
						{
							string Username = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(Username, String.IsNullOrWhiteSpace(item.Username+"") ? "" : item.Username));
						 })
                   , grid.Column(header: "Salt", style: "width_100per", columnName: "Salt",
						format: item =>
						{
							string Salt = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(Salt, String.IsNullOrWhiteSpace(item.Salt+"") ? "" : item.Salt));
						 })
                   , grid.Column(header: "Surname", style: "width_100per", columnName: "Surname",
						format: item =>
						{
							string Surname = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(Surname, String.IsNullOrWhiteSpace(item.Surname+"") ? "" : item.Surname));
						 })
                   , grid.Column(header: "Mobile", style: "width_100per", columnName: "Mobile",
						format: item =>
						{
							string Mobile = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(Mobile, String.IsNullOrWhiteSpace(item.Mobile+"") ? "" : item.Mobile));
						 })
                   , grid.Column(header: "Email", style: "width_100per", columnName: "Email",
						format: item =>
						{
							string Email = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(Email, String.IsNullOrWhiteSpace(item.Email+"") ? "" : item.Email));
						 })
                   , grid.Column(header: "PicturePath", style: "width_100per", columnName: "PicturePath",
						format: item =>
						{
							string PicturePath = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(PicturePath, String.IsNullOrWhiteSpace(item.PicturePath+"") ? "" : item.PicturePath));
						 })
                   , grid.Column(header: "SurveyorLocation", style: "width_100per", columnName: "SurveyorLocation",
						format: item =>
						{
							string SurveyorLocation = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(SurveyorLocation, String.IsNullOrWhiteSpace(item.SurveyorLocation+"") ? "" : item.SurveyorLocation));
						 })
			    
        ));
    }
    else
    {
    <div class="emptyRow">No item base on search criteria that you had inputed.</div>
    
    }
 }
</body>